n = int(input())
costs = []
times = []
for _ in range(n):
    c, t = map(int, input().split())
    costs.append(c)
    times.append(t)
dp = dict()  # 得到小于等于i个物品至少要花dp[i]
dp[0] = 0
inf = float('inf')
for i in range(n):  # 物品
    if times[i] > n:
        dp[n] = min(dp.get(n, inf), costs[i])
    for j in range(n, times[i], -1):  # 容量
        dp[j] = min(dp.get(n, inf), dp.get(j - times[i] - 1, inf) + costs[i])
